namespace KPIS.GERP.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class update0108 : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.SysOTPData", "UniqueId", "dbo.SysOTP");
            DropIndex("dbo.SysOTPData", new[] { "UniqueId" });
            AddColumn("dbo.SysOTP", "OtpId", c => c.Int(nullable: false, identity: true));
            AddColumn("dbo.SysOTP", "CreatedWhen", c => c.DateTime(nullable: false));
            AddColumn("dbo.SysOTPData", "OTP_OtpId", c => c.Int());
            AlterColumn("dbo.SysOTP", "UniqueId", c => c.Guid(nullable: false));
            DropPrimaryKey("dbo.SysOTP", new[] { "UniqueId" });
            AddPrimaryKey("dbo.SysOTP", "OtpId");
            AddForeignKey("dbo.SysOTPData", "OTP_OtpId", "dbo.SysOTP", "OtpId");
            CreateIndex("dbo.SysOTPData", "OTP_OtpId");
            DropColumn("dbo.SysOTPData", "UniqueId");
        }
        
        public override void Down()
        {
            AddColumn("dbo.SysOTPData", "UniqueId", c => c.Guid(nullable: false));
            DropIndex("dbo.SysOTPData", new[] { "OTP_OtpId" });
            DropForeignKey("dbo.SysOTPData", "OTP_OtpId", "dbo.SysOTP");
            DropPrimaryKey("dbo.SysOTP", new[] { "OtpId" });
            AddPrimaryKey("dbo.SysOTP", "UniqueId");
            AlterColumn("dbo.SysOTP", "UniqueId", c => c.Guid(nullable: false, identity: true));
            DropColumn("dbo.SysOTPData", "OTP_OtpId");
            DropColumn("dbo.SysOTP", "CreatedWhen");
            DropColumn("dbo.SysOTP", "OtpId");
            CreateIndex("dbo.SysOTPData", "UniqueId");
            AddForeignKey("dbo.SysOTPData", "UniqueId", "dbo.SysOTP", "UniqueId", cascadeDelete: true);
        }
    }
}
